package com.alibaba.citrus.cr.sales.plan.repository;

import com.alibaba.citrus.cr.sales.plan.dto.api.request.PageQueryPlanLineRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.QuerySalesPlanLineRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.SalesPlanBatchQueryRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.SalesPlanDetailBatchQueryRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.SalesPlanSubTotalRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.response.SalesPlanSubTotalResponse;
import com.alibaba.citrus.cr.sales.plan.repository.request.StatCustomerQueryRequest;
import com.alibaba.citrus.cr.sales.plan.repository.request.StatScItemQueryRequest;
import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanLineSDO;
import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanStatCustomerSDO;
import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanStatScItemSDO;
import com.alibaba.cz.base.tool.page.PageResult;
import com.epoch.app.bcorder.sales_plan.salesplandetail.dto.SubTotalSalesPlanLineRequest;
import com.epoch.app.bcorder.model.dto.SalesPlanSDO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author wangyibing
 */

public interface SalesPlanLineRepository {

    String save(SalesPlanLineSDO salesPlanLineSDO);

    SalesPlanLineSDO querySalesPlanLine(QuerySalesPlanLineRequest querySalesPlanLineRequest);

    Integer edit(SalesPlanLineSDO salesPlanLineSDO);

    Integer delete(SalesPlanLineSDO salesPlanLineSDO);

    /**
     * 更新初始任务量
     *
     * @param planId
     * @return
     */
    Integer updateInitTaskCount(Long planId);

    /**
     * 批量新增月度计划明细
     *
     * @param createPlanLineSDOList
     * @return
     */
    String batchCreateSalesPlanLine(List<SalesPlanLineSDO> createPlanLineSDOList);

    /**
     * 分页查询明细
     *
     * @param pageQuerySalePlanRequest
     * @return
     */
    PageResult<List<SalesPlanLineSDO>> pageQuerySalesPlanLineList(PageQueryPlanLineRequest pageQuerySalePlanRequest);

    /**
     * 月度计划明细小计
     *
     * @param subTotalSalesPlanLineRequest
     * @return
     */
    SalesPlanSubTotalResponse subTotalSalesPlanLine(SubTotalSalesPlanLineRequest subTotalSalesPlanLineRequest);

    /**
     * 查询计划客户地址总数
     *
     * @param planId
     * @return
     */
    Integer queryPlanCustomerCount(Long planId, List<Integer> statusList);

    /**
     * 批量删除明细(变更状态)
     *
     * @param salesPlanLineSDOList
     * @return
     */
    Integer batchUpdateLineStatus(List<SalesPlanLineSDO> salesPlanLineSDOList);

    /**
     * 明细汇总客户信息
     *
     * @param statQueryRequest
     * @return
     */
    List<SalesPlanStatCustomerSDO> queryStatPlanCustomerList(StatCustomerQueryRequest statQueryRequest);

    /**
     * 月度计划明细完成进度占比
     *
     * @param salesPlanSubTotalRequest
     * @return
     */
    BigDecimal queryCompletePercent(SalesPlanSubTotalRequest salesPlanSubTotalRequest);

    /**
     * 查询汇总货品信息
     *
     * @param statQueryRequest
     * @return
     */
    List<SalesPlanStatScItemSDO> queryStatPlanScItemList(StatScItemQueryRequest statQueryRequest);

    /**
     * 根据条件查询明细(用于新增明细已维护地址置灰)
     *
     * @param salesPlanSubTotalRequest
     * @return
     */
    List<String> querySalesPlanLineByCustomerAddress(SalesPlanSubTotalRequest salesPlanSubTotalRequest);

    /**
     * 根据ids批量查询明细
     *
     * @param salesPlanDetailBatchQueryRequest
     * @return
     */
    List<SalesPlanLineSDO> batchQueryDetailByIds(SalesPlanDetailBatchQueryRequest salesPlanDetailBatchQueryRequest);

    /**
     * 根据条件批量查询明细
     *
     * @param salesPlanBatchQueryRequest
     * @return
     */
    List<SalesPlanLineSDO> batchQueryDetail(SalesPlanBatchQueryRequest salesPlanBatchQueryRequest);

    /**
     * 根据条件查询明细(用于新增明细已维护货品置灰)
     *
     * @param salesPlanSubTotalRequest
     * @return
     */
    List<String> querySalesPlanLineByScItem(SalesPlanSubTotalRequest salesPlanSubTotalRequest);

    /**
     * 分页查询调整新增明细
     *
     * @param pageQuerySalePlanRequest
     * @return
     */
    PageResult<List<SalesPlanLineSDO>> pageQuerySalesPlanLineAdjustAddList(PageQueryPlanLineRequest pageQuerySalePlanRequest);

    /**
     * 批量更新计划明细
     *
     * @param request
     * @return
     */
    Integer batchUpdateById(List<SalesPlanLineSDO> request);

    /**
     * 统计月度计划明细数量
     *
     * @param planIdList
     * @return
     */
    Map<Long,SalesPlanSDO> statisticalPlanDetailCount(List<Long> planIdList);

    /**
     * 查询计划明细最大行号
     * @param planId
     * @return
     */
    Long queryMaxPlanLineNo(Long planId);

}
